import http from "../axios";

export const uploadApi = (params: Base.GeneraDataType, data: Base.GeneraDataType) => {
  return http({
    method: "post",
    url: "/base/sys/upload",
    data,
    params,
    headers: {
      "Content-type": "multipart/form-data"
    }
  });
};
export const batchUploadApi = (params: Base.GeneraDataType, data: Base.GeneraDataType) => {
  return http({
    method: "post",
    url: "/base/sys/uploadBatch",
    data,
    params,
    headers: {
      "Content-type": "multipart/form-data"
    }
  });
};
// 附件删除
export const deleteFileByIdApi = (data: { id: string; fileUrl: string }) => {
  return http({
    method: "post",
    url: "/base/sys/delete",
    data
  });
};
// 获取省市州 树形
export const getProvinceApi = (data: Base.GeneraDataType = {}) => {
  return http({
    method: "post",
    url: "/base/sys/baseProvinces/divisionTree",
    data
  });
};
// 根据端口获取当前客户拥有的 所有模块
export const getAllClientCodeApi = () => {
  return http({
    method: "post",
    url: "/base/biz/client/list"
  });
};
// 根据岗位过滤用户
export const getUserByPositionApi = (data: { position?: number; status?: number }) => {
  return http({
    method: "post",
    url: "/base/biz/user/list/position",
    data
  });
};
// 获取操作日志
export const getOperationLogApi = (data: { businessId: string; sysModule: string }): Promise<any> => {
  return http({
    url: `/base/biz/bizOperateLog/listByBusinessId`,
    method: "post",
    data
  });
};
// 获取省
export const getProvinceListApi = (params: Base.GeneraDataType = {}) => {
  return http({
    method: "get",
    url: "/base/sys/baseProvinces/selectProvinceList",
    params
  });
};
// 根据省code 获取市区
export const getCityListByProvinceApi = (code: string) => {
  return http({
    method: "get",
    url: `/base/sys/baseCities/selectCityByProvince/${code}`
  });
};
// 根据市code 获取县
export const getAreaListByCityApi = (code: string) => {
  return http({
    method: "get",
    url: `/base/sys/baseAreas/selectAreaListByCity/${code}`
  });
};
// 根据区code 获取街道
export const getStreetListByAreaApi = (code: number | string) => {
  return http({
    method: "get",
    url: `/base/sys/baseStreets/selectStreetListByArea/${code}`
  });
};
// 根据国家或地区 获取 渠道
export const getChannelByCountryApi = (counrtyAndRegionId: string) => {
  return http({
    url: `/base/biz/bizWarehouseChannel/selectByCountryAndRegionId/${counrtyAndRegionId}`,
    method: "get"
  });
};

// 根据国家或地区 获取 渠道(客户端)
export const getCoumsterChannelByCountryApi = (data: Base.GeneraDataType) => {
  return http({
    url: `/base/biz/bizWarehouseChannel/selectByCountryRegion`,
    method: "post",
    data
  });
};

// 获取所有客户
export const getAllCustomerApi = (data: Base.GeneraDataType) => {
  return http({
    url: `/base/biz/customer/getCustomerSelectList`,
    method: "post",
    data
  });
};
// 跟进部门ID过滤 用户
export const getUserByDeptIdApi = (id: string) => {
  return http({
    url: `/base/sys/user/getUserListByDeptId/${id}`,
    method: "get"
  });
};
// 根据客户 ID 获取 取件地址
export const getPickAddressByCusIddApi = (data: Base.GeneraDataType) => {
  return http({
    url: `/base/biz/customer/pickup/address/chooseAddressPage`,
    method: "post",
    data
  });
};
// 下载模板
export const downloadTemplateApi = (params: { type: number }) => {
  return http({
    url: `/base/biz/excel/getImportTemplate`,
    method: "get",
    params
  });
};
// 获取 列表自定义字段配置
export const getUserCustomConfigApi = () => {
  return http({
    url: `/base/biz/listCustomFieldConfig/getFieldConfigJson`,
    method: "post"
  });
};
// 保存 列表自定义字段配置
export const updateUserCustomConfigApi = (data: string) => {
  return http({
    url: `/base/biz/listCustomFieldConfig/saveOrUpdateConfig`,
    method: "post",
    data
  });
};
// 下载运单货单 PDF
export const printLabelApi = (data: { idList: string[]; type?: number; buttonType?: number }) => {
  return http({
    url: `/base/biz/bizCfgTemplatePdf/downloadShipmentBoxLabelByIdList`,
    method: "post",
    data,
    responseType: "blob",
    headers: {
      enable: true
    }
  });
};
// 根据国家获取仓库代码 级联
export const getWarehouseCodeByCountryIdApi = (countryId: string) => {
  return http({
    url: `/base/biz/bizWarehouseCodeManage/selectByCountryIdGroup/${countryId}`,
    method: "get"
  });
};
// 获取登录页 背景图
export const getLoginBgApi = () => {
  return http({
    url: `/base/sys/getInfoBySubdomain`,
    method: "post"
  });
};
